package com.consumer.feign;

import com.consumer.feign.fallback.TestServiceFallback;
import com.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;

// 服务降级一定要在配置文件开启 feign.hystrix.enabled=true
@FeignClient(name = "service-provider",fallback = TestServiceFallback.class)
public interface TestService {

    @GetMapping("/test/provider/{name}")
    public String test(@PathVariable String name);

    @GetMapping("/getUser")
    public User getUser(@SpringQueryMap User user);

    @PostMapping(
        value = "/upload",
        produces = MediaType.APPLICATION_JSON_VALUE,
        consumes = MediaType.MULTIPART_FORM_DATA_VALUE
    )
    public String upload(@RequestBody MultipartFile file);
}
